package sjtu.ist.warehouse4ws.action;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.json.annotations.JSON;

import sjtu.ist.warehouse4ws.jcr.RepositoryMoudl;
import sjtu.ist.warehouse4ws.tool.XmlFileToString;

import com.opensymphony.xwork2.ActionSupport;

public class ShowXmlContentAction extends ActionSupport{
private XmlFileToString xmlString;
private String xmlContent;
RepositoryMoudl repositoryMoudlService;
public void setRepositoryMoudlService(RepositoryMoudl repositoryMoudlService) {
	this.repositoryMoudlService = repositoryMoudlService;
}


public String getXmlContent() {
	return xmlContent;
}

public void setXmlContent(String xmlContent) {
	this.xmlContent = xmlContent;
}

public void setXmlString(XmlFileToString xmlString) {
	this.xmlString = xmlString;
}
//XML内容进行分文件读取
public String showXmlContent(){
	HttpServletRequest request = ServletActionContext.getRequest ();
	String pathName=request.getParameter("pathName");
	xmlContent=repositoryMoudlService.getModelXmlContent(pathName);      //这里对JSON数据进行处理，使之能够换行
	xmlContent=xmlContent.replaceAll("\r\n", "lineChange");  
	xmlContent=xmlContent.replaceAll("\n", "lineChange");   
	xmlContent=xmlContent.replaceAll("/", "slash");
	xmlContent=xmlContent.replaceAll("\"", "quotation");
	System.out.print(xmlContent);
	return SUCCESS;
}



}
